package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.mapper.LogMapper;
import com.itheima.pojo.Emp;
import com.itheima.pojo.OperateLog;
import com.itheima.pojo.OperateLogQueryParam;
import com.itheima.pojo.PageResult;
import com.itheima.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class LogServiceImpl implements LogService {
    @Autowired
    private LogMapper logMapper;
    @Override
    public PageResult page(OperateLogQueryParam operateLogQueryParam) {
        PageHelper.startPage(operateLogQueryParam.getPage(),operateLogQueryParam.getPageSize());
//        // 2. 执行查询，返回List<Emp>
//        List<Emp> empList = empMapper.page(empQueryParam);
        List<OperateLog> operateLog =logMapper.page(operateLogQueryParam);
//        // 3. 封装分页结果
//        Page<Emp> page = (Page<Emp>) empList;
        Page<OperateLog> page = (Page<OperateLog>)operateLog;
//        // 4. 返回PageResult对象
//        return new PageResult(page.getTotal(), page.getResult());
        return new PageResult(page.getTotal(),page.getResult());
    }
}
